﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GmStructure.h"
#include "IElementJoinBehavior.h"

namespace gcmp
{
    class IDocument;
    class ElementId;

    /// \brief Instance的连接行为
    class GM_STRUCTURE_EXPORT IStructureInstanceJoinBehavior : public IElementJoinBehavior
    {
        DEFINE_CAST_DERIVED(gcmp::IStructureInstanceJoinBehavior, gcmp::IElementJoinBehavior)

    public:

        /// \brief 创建Instance的连接行为
        /// \param pDocument 当前文档
        /// \param joinType 连接类型
        /// \param isChangeJoinTypeAllowed 是否允许切换连接类型
        /// \return 连接行为
        static OwnerPtr<IElementJoinBehavior> CreateInstanceJoinBehavior(IDocument* pDocument, JoinType joinType, bool isChangeJoinTypeAllowed = true);

        /// \brief 获取连接类型
        /// \return 连接类型
        virtual JoinType GetJoinType() = 0;

        /// \brief 判断是否允许切换平接与方接
        /// \return 返回true代表允许，返回false代表不允许
        virtual bool IsChangeJoinTypeAllowed() const = 0;

        /// \brief 设置是否允许切换平接与方接
        /// \param isChangeJoinTypeAllowed 是否允许切换平接与方接，true代表允许，false代表不允许
        /// \return 成功返回true，失败返回false
        virtual bool SetIsChangeJoinTypeAllowed(bool isChangeJoinTypeAllowed) = 0;

        /// \brief 判断是否允许切换主次关系
        /// \return 返回true代表允许，返回false代表不允许
        virtual bool IsChangePriAndSecAllowed() const = 0;

        /// \brief 设置是否允许切换主次关系
        /// \param isChangePriAndSecAllowed 是否允许切换主次关系，true代表允许，false代表不允许
        /// \return 成功返回true，失败返回false
        virtual bool SetIsChangePriAndSecAllowed(bool isChangePriAndSecAllowed) = 0;

        /// \brief 获得连接类型RdId
        /// \return 连接类型的RdId
        virtual RegenDataId GetElementJoinTypeRdId() const = 0;

        /// \brief 标记连接类型RdId
        /// \return void
        virtual void MarkElementJoinTypeRdId() = 0;
    };
}
